import { siteGroupList } from '@/api/SiteGroupApi.ts'
import { useSiteGroupStore } from '@/config/store/UseSiteGroupStore.ts'


export class SiteGroupService {


    public initGroupList(): void {
        const groupStore = useSiteGroupStore()

        groupStore.groupIsLoading = true
        siteGroupList()
                .then(list => {
                    groupStore.groupList = list.sort((a, b) => a.sort - b.sort)
                    groupStore.selectFirst()
                })
                .finally(() => groupStore.groupIsLoading = false)
    }

}
